import axios from './request';

// 获取授课包

export async function listSelfTeachPackage ({ sourceCode }) {
  const {
    data
  } = await axios.get(
    `${process.env.VUE_APP_NRMS_URL}/rms/v1/teachpackage/list_self_teach_package`,
    { params: { sourceCode } }
  );

  return data;
}
// 推荐资源获取
export async function getRecommendList (catId) {
  const {
    data
  } = await axios.get(
    `${process.env.VUE_APP_NRMS_URL}/rms/v1/attention/get_recommond_list`,
    { params: { catId } }
  );
  return data;
}

// 资源播放
export async function getPlayList ({ resId, fileId, ct, filterType, docPreviewType }) {
  const {
    data
  } = await axios.get(
    `${process.env.VUE_APP_NRMS_URL}/rms/v1/rmsreses/play_list`,
    { params: { resId, fileId, ct, filterType, docPreviewType } }
  );

  return data;
}

// 课程资源列表个性显示接口
export async function getCourseList ({ paramTags, catId }) {
  const { data } = await axios.get(
    `${process.env.VUE_APP_NRMS_URL}/rms/v1/rmsreses/special_infos`,
    {
      params: {
        paramTags,
        catId
      }
    }
  );

  return data;
}

// 关注列表
export async function getAttentionList (catId) {
  const { data } = await axios.get(
    `${process.env.VUE_APP_NRMS_URL}/rms/v1/attention/get_attention_list`,
    {
      params: {
        catId
      }
    }
  );

  return data;
}

// 关注列表
export async function getHotList (sourceCode, queryType) {
  const { data } = await axios.get(
    `${process.env.VUE_APP_NRMS_URL}/rms/v1/attention/get_attention_list`,
    {
      params: {
        sourceCode,
        queryType
      }
    }
  );

  return data;
}
// 资源点赞
export async function addPraise ({ objectType, objectId }) {
  // const { data } = await axios.post(`${process.env.VUE_APP_COMMENT_URL}/v1/praise/add_praise`, { objectType, objectId }
  // const { data } = await axios.post('http://center.bigwoniu.com/gw/commentapi/comment/v1/praise/add_praise', JSON.stringify({ objectType, objectId })
  const { data } = await axios.get(
    `${process.env.VUE_APP_COMMENT_URL}/v1/praise/add_praise`,
    {
      // const { data } = await axios.get('http://center.bigwoniu.com/gw/commentapi/comment/v1/praise/add_praise', {
      params: {
        objectType,
        objectId
      }
    }
  );
  return data;
}
// 资源点赞数量查询
export async function getPraiseNum ({ objectType, objectId }) {
  const { data } = await axios.get(
    `${process.env.VUE_APP_COMMENT_URL}/v1/praise/get_praise_info`,
    {
      // const { data } = await axios.get('http://center.bigwoniu.com/gw/commentapi/comment/v1/praise/get_praise_info', {
      params: {
        objectType,
        objectId
      }
    }
  );

  return data;
}
// 资源纠错入库
export async function addCorrect ({
  objectType,
  objectId,
  mistakeCategory,
  mistakeDescription,
  mistakeImage
}) {
  const { data } = await axios.post(
    `${process.env.VUE_APP_COMMENT_URL}/v1/correct/add_correct`,
    { objectType, objectId, mistakeCategory, mistakeDescription, mistakeImage }
    // const { data } = await axios.post('http://center.bigwoniu.com/gw/commentapi/comment/v1/correct/add_correct', { objectType, objectId, mistakeCategory, mistakeDescription, mistakeImage }
  );

  return data;
}
// 资源评论入库
export async function addComment ({ objectType, objectId, content, parentId }) {
  const { data } = await axios.post(
    `${process.env.VUE_APP_COMMENT_URL}/v1/comment/add_comment`,
    { objectType, objectId, content, parentId }
    // const { data } = await axios.post('http://center.bigwoniu.com/gw/commentapi/comment/v1/comment/add_comment', { objectType, objectId, content, parentId }
  );

  return data;
}
// 资源评论查询列表
export async function getCommentList ({
  objectType,
  objectId,
  pageNum,
  pageSize,
  fetchType
}) {
  const { data } = await axios.get(
    `${process.env.VUE_APP_COMMENT_URL}/v1/comment/get_comment_list`,
    {
      // const { data } = await axios.get('http://center.bigwoniu.com/gw/commentapi/comment/v1/comment/get_comment_list', {
      params: {
        objectType,
        objectId,
        pageNum,
        pageSize,
        fetchType
      }
    }
  );

  return data;
}
// 资源纠错查询列表
export async function getCorrectList ({
  solveStatus,
  objectType,
  pageNum,
  pageSize,
  objectCode
}) {
  const { data } = await axios.get(
    `${process.env.VUE_APP_NRMS_URL}/comment/v1/correct/get_correct_list`,
    {
      params: {
        solveStatus,
        objectType,
        pageNum,
        pageSize,
        objectCode
      }
    }
  );

  return data;
}
// 资源推荐接口
export async function recommedFiles ({
  fileIds,
  recipientList,
  resIds,
  message
}) {
  const {
    data
  } = await axios.post(
    `${process.env.VUE_APP_NRMS_URL}/rms/v1/cloud/recommed_file`,
    { fileIds, recipientList, resIds, message }
  );

  return data;
}
// 获取用户信息
export async function getTokenInfo () {
  const { data } = await axios.get(
    `${process.env.VUE_APP_UC_URL}/sso/api/v2/getTokenInfo`
  );
  return data;
}
